﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using System.IO;

namespace Citi.GocAttributes.WebUI.Controllers
{
    public class PartialViewController : ControllerBase
    {
        //[HttpGet]
        //public ActionResult Upload()
        //{
        //    var fileUpload = new Models.UploadModel { Path = uploadFolder };
        //    return PartialView(fileUpload);
        //}

        [HttpPost]
        public ActionResult Upload(HttpPostedFileBase fileData)
        {
            using (Helpers.NetworkShareAccesser.Access(UploadFolder, NetworkUser, NetworkPassword))
            {
                if (!Directory.Exists(UploadFolder))
                    Directory.CreateDirectory(UploadFolder);

                //foreach (var file in files)
                {
                    var fileToSave = Path.Combine(UploadFolder, Path.GetFileName(fileData.FileName));
                    fileData.SaveAs(fileToSave);
                }
            }

            return Json(new
              {
                  success = true
              });
        }
    }
}
